import bean.Team;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @ClassName: text
 * @Description:
 * @Date Created in  2021-08-31 10:30
 * @Modified By:
 * @Author: 零巽
 */
public class Text {
    @Test
    public void test1() {
        //创建spring容器对象
        String path = "application.xml";
        ApplicationContext context = new ClassPathXmlApplicationContext(path);
        //获取容器中的bean
        Team team = context.getBean("team", Team.class);
        //获取容器中对象数量的方法
        int beanDefinitionCount = context.getBeanDefinitionCount();
        System.out.println("共有" + beanDefinitionCount + "个bean对象");
        //获取容器中对象的名字
        String[] beanDefinitionNames = context.getBeanDefinitionNames();
        for (String name:beanDefinitionNames
             ) {
            System.out.println("名字为"+name);
        }

    }
}
